/*
 *             Copyright (C) 2024 Steve Jrong
 *
 * 	   GitHub Homepage: https://www.github.com/SteveJrong
 *      Gitee Homepage: https://gitee.com/stevejrong1024
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.stevejrong.waiter.rp.event.handler;

import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.stereotype.Service;

import com.stevejrong.waiter.mq.message.component.AbstractEventHandler;
import com.stevejrong.waiter.rp.api.IMerchantUserPermissionApplicationService;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 领域事件监听器 - 发布获取三大用户平台（顾客端、商家用户端和系统超级管理员端）的权限URL和权限Code的消息
 *
 * @author Steve Jrong
 * @since 1.0
 */
@Service
@Slf4j
@AllArgsConstructor
public class GetUserPermissionUrlAndCodeEventHandler extends AbstractEventHandler {
    private IMerchantUserPermissionApplicationService merchantUserPermissionApplicationService;

    @Override
    protected String setConsumerBeanName() {
        return "waiterAuthAppConsumer";
    }

    @Override
    protected void consume(MessageExt messageExt) {
        merchantUserPermissionApplicationService.listAllBackendPermission(messageExt.getTags().replaceAll("REQUEST_", ""));
    }
}